package org.example.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.example.dao.StaffDao;
import org.example.entity.Staff;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@RequiredArgsConstructor
public class StaffService {
    private final StaffDao dao;
    public List<Staff> list() {
        List<Staff> res = new ArrayList<>();
        return dao.selectList(Wrappers.emptyWrapper());
    }

    public List<Staff> list(String name) {
        return dao.selectList(Wrappers.<Staff>lambdaQuery().eq(Staff::getName, name));
    }

    public List<Staff> list(Integer age) {
        return dao.selectList(Wrappers.<Staff>lambdaQuery().gt(Staff::getAge, age));
    }

    public void add(Staff staff) {
        dao.insert(staff);
        return;
    }
}
